angular.module('Controller')
.controller('WFParamsSettingEditCtrl', ($scope,NgTableParams,commonUtil,commonConstant,$http,$rootScope, $uibModalInstance, items) ->
  type=items.type
  $scope.data=items.data
  $scope.modalTitle=if type=='new' then '新建参数字典' else '编辑参数字典'

  $scope.modalStatusList=commonConstant.enabledList()
  $scope.newData=()->
    postData={
      name:$scope.data.name
      dicIndexId:$rootScope.pageParams.id
      enabled: $scope.data.enabled
      sort:0
      remark:$scope.data.remark
    }
    getParams=commonUtil.transferGetParam(postData)
    $http.post('/dictionary/',postData)
    .success((resp)->
      console.log('新增参数字典:',resp)
      $uibModalInstance.close('done')
    )
  $scope.editData=()->
    putData={
      name:$scope.data.name
      dicIndexId:$rootScope.pageParams.id
      enabled: $scope.data.enabled
      sort:0
      remark:$scope.data.remark
    }
    getParams=commonUtil.transferGetParam(putData)
    $http.put('/dictionary/'+$scope.data.id,putData)
    .success((resp)->
      console.log('修改参数字典:',resp)
      $uibModalInstance.close('done')
    )
  $scope.judge=()->
    if type=='new'
      false
    else
      true
  $scope.confirm = ()->
    if type=='new'
      $scope.newData()
    else
      $scope.editData()
  $scope.cancel =()->
    $uibModalInstance.dismiss('cancel')

)